package cn.com.ninng.sort;

/**
 * @author liulekang
 * @createdate 2021/7/22
 */
public class Sort {

    public static void main(String[] args) {
        int[] a = new int[]{3,2,4,5,8,1,0,7};

        int[] ints = bubbleSort(a);
        for (int anInt : ints) {
            System.out.println(anInt);
        }
    }

    public static int[] bubbleSort(int[] nums) {

        for (int i = 0; i < nums.length - 1; i++) {
            for (int j = 0; j < nums.length - 1 - i; j++) {
                if (nums[j] < nums[j + 1]) {
                    int tmp = nums[j+1];
                    nums[j+1] = nums[j];
                    nums[j] = tmp;
                }
            }
        }
        return nums;
    }
}
